<?php
require_once './admin-header.php';
if (!isset($_SESSION['uid']) || !isset($_GET['tid'])) {
    ?>
    <script>history.go(-1);</script>
    <?php
    return 0;
} else {
    $uid = $_SESSION['uid'];
    $tid = $_GET['tid'];
}
require_once './core/admin-sql.php';
$sql = new AdminSql();
?>
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=0,maximum-scale=1.0"/>
        <title>我的报名</title>
        <link rel="stylesheet" href="../css/base.css">
        <link rel="stylesheet" href="../css/index.css">
        <link rel="stylesheet" href="./css/jquery.xctips.css"/>

        <script>
            function adapte() {//适配
                var designWidth = 1080, rem2px = 100;
                document.documentElement.style.fontSize = window.innerWidth / designWidth * rem2px + "px";
            }
            adapte();
        </script>
        <style>
        </style>
    </head>
    <body>
    <div class="my-apply2 fs36">
        <div class="apply-top">
            <ul class="flex2">
                <li class="check-all check1">全选</li>
                <li>
                    <button class="del"><a class="fs36" href="javascript:;"
                                           onclick="deleteApply2(<?= $uid ?>, <?= $tid ?>)">删除</a></button>
                    /
                    <button><a class="fs36" href="javascript:;">导出</a></button>
                </li>
            </ul>
        </div>
        <div class="apply-bottom">
            <ul class="list">
                <?php
                $allUserArray = $sql->searchUsersFromTaId($uid, $tid);
                if ($allUserArray[0] === 0) {
                    list($static_users, $num_users, $userId_array) = $allUserArray;
                    for ($i = 0; $i < $num_users; $i++) {
                        $userId = $userId_array[$i];
                        $allUserFormArray = $sql->searchUsersForm($userId, $uid, $tid);
                        if ($allUserFormArray[0] === 0) {
                            $formArray = $allUserFormArray[1];
                            $textName = isset($formArray['学生姓名']) ? $formArray['学生姓名'][0] : '';
                            $textPhone = isset($formArray['家长手机']) ? $formArray['家长手机'][0] : '';
                            $textCourses = isset($formArray['课程选择']) ? $formArray['课程选择'] : [''];
                        }
                        ?>
                        <li class="check1 check">
                            <id style="display: none;"><?= $userId ?></id>
                            <a href="myApply3.php?uid=<?= $uid ?>&tid=<?= $tid ?>&bid=<?= $userId ?>">
                                <ul class="list1 flex2">
                                    <li>&nbsp;<?= $textName ?>&nbsp;</li>
                                    <li class="apply-phone">&nbsp;<?= $textPhone ?>&nbsp;</li>
                                    <li class="apply-course">
                                        <ul class="list2 flex">
                                            <?php
                                            $courseNum = count($textCourses);
                                            for ($j = 0; $j < $courseNum; $j++) {
                                                ?>
                                                <li>&nbsp;<?= $textCourses[$j] ?>&nbsp;</li>
                                                <?php
                                            }
                                            ?>
                                        </ul>
                                    </li>
                                </ul>
                            </a>
                        </li>
                        <?php
                    }
                }
                ?>
            </ul>
        </div>
    </div>
    <script src='../script/jquery.js'></script>
    <script src='../script/index.js'></script>
    </body>
    </html>
<?php
if (isset($_GET['delete'])) {
    ?>
    <script>
        xcsoft.success('删除成功', 1000);
    </script>
    <?php
}
require_once './admin-footer.php';